package com.yc.cloud.api.enums;

import lombok.Getter;

/**
 * @author 橘子
 * @version 1.0
 * @description: 硬件设备状态枚举
 * @date 2024-07-28 10:00
 */
@Getter
public enum HWDeviceStatus {

    OFFLINE(0, "离线"),
    ONLINE(1, "在线"),
    FAULT(2, "故障");

    private final Integer code;
    private final String description;

    HWDeviceStatus(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    /**
     * 根据编码查找枚举
     *
     * @param code 编码
     * @return {@link HWDeviceStatus} 实例
     **/
    public static HWDeviceStatus find(Integer code) {
        for (HWDeviceStatus instance : HWDeviceStatus.values()) {
            if (instance.getCode().equals(code)) {
                return instance;
            }
        }
        return null;
    }
} 